using System;
using System.IO;
using MonsterNet;

namespace MonsterNetTests
{
	
	public class SetupTearDownDirectories
	{
		public const string kTestRootDirName = @"Test";
		public const string kTestChildDirName1 = @"Test1";
		public const string kTestChildDirName2 = @"Test2";
		public const string kTestRootFileName = @"ThisIsATestFile.test";
		public const string kTestChildFileName1 = @"ThisIsATestFile1.test";
		public const string kTestChildFileName2 = @"ThisIsATestFile2.test";
	
		private string _pathname;

		public string Pathname {
			get {
				return this._pathname;
			}
			set {
				_pathname = value;
			}
		}
		
		
		private void CreateFile(string path, string filename) {
			FileStream fs = System.IO.File.Create(Path.Combine(path,filename));
			fs.Close();
		}	
		
		public void SetupDirectory() {
			
			_pathname = System.IO.Path.Combine(MNGlobal.DefaultDirectory(), kTestRootDirName);
			Directory.CreateDirectory(_pathname);			
					
			Directory.CreateDirectory(Path.Combine(_pathname, kTestChildDirName1));
			Directory.CreateDirectory(Path.Combine(_pathname, kTestChildDirName2));
			
			CreateFile(_pathname,kTestRootFileName);
			CreateFile(Path.Combine(_pathname,kTestChildDirName1), kTestChildFileName1);
			CreateFile(Path.Combine(_pathname,kTestChildDirName1), kTestChildFileName2);
			CreateFile(Path.Combine(_pathname,kTestChildDirName2), kTestChildFileName1);	
			CreateFile(Path.Combine(_pathname,kTestChildDirName2), kTestChildFileName2);				
		}
		
		public void TearDownDirectory() {
			
			try {
				if(System.IO.Directory.Exists(_pathname))
					System.IO.Directory.Delete(_pathname,true);
			} catch {}				
			
		}
	}
}

